function regex() {
    var num1 = document.getElementById("1").value;
    var num2 = document.getElementById("2").value;
    var num3 = document.getElementById("3").value;
    var num4 = document.getElementById("4").value;

    if (!/^\d$/.test(num1)) {
        alert("wrong1");
        return;
    }

    if (!/^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/.test(num2)) {
        alert("wrong2");
        return;
    }

    if (!/\./.test(num3)) {
        alert("wrong3");
        return;
    }

    if (!/^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/.test(num4)) {
        alert("wrong4");
        return;
    }
}

function init() {
    var button = document.getElementsByTagName("button")[0];
    button.onclick = function () {
        regex();
    }
}

function load() {
    init();
}